<script setup>
//watch监听的immediate立即监听，作用跟vue2一样
import { ref, watch } from 'vue'
const count = ref(0)
watch(count, (newVal, oldVal) => {
  console.log('newVal', newVal)
  console.log('oldVal', oldVal)
},{
  immediate: true
}) 
</script>

<template>
  <div>
    count: {{ count }}
  </div>
  <button @click="count++">count++</button>
  <div>age: {{ age }}</div>
  <button @click="age++">age++</button>
</template>

<style lang="scss" scoped>

</style>
